#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int a[N];
int main()
{
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	int T;
	cin>>T;
	while(T--)
	{
		long long ans=0;
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			int x;
			cin>>x;
			a[x]++;
		}
		for(int i=1;i<=1000050;i++)
		{
			ans+=a[i]/2*i;
			a[i]=0;
		}
		cout<<ans<<endl;
	}
	return 0;
}
